package com.icehand.controller;

import com.icehand.model.Greeting;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.atomic.AtomicLong;

/**
 *
 * Created by icehand on 2017/5/11.
 */
@RestController
@EnableAutoConfiguration
public class HelloController {

	private static final String template = "welcome,%s!";

	private final AtomicLong counter = new AtomicLong();

	@RequestMapping("/")
	public String index(){
		return "hello";
	}

	@RequestMapping(value="/greet")
	public Greeting greeting(@RequestParam(value ="name",required = false,defaultValue = "Stranger")String name){
		return new Greeting(counter.incrementAndGet(),name);
	}
}
